1. /* slflpwmd.cpp by K.Tsuru */
  2. // function ID = 2005 DRADIX
  3. /***********************************
  4. SLong class
  5. It provides the value of M^d mod n.
  6. ************************************/
  7. #ifndef SN_H
  8. #include "sn.h"
  9. #endif
  10. SLong MpowMod(const SLong& M, ulong d, const SLong& n){
  11. SLong x(1), m(M);
  12. if(d == 0) return x; // = 1
  13. while(d){
  14. if( (d % 2) == 0){
  15. d /= 2;
  16. m = (m*m) % n;
  17. } else {
  18. d--;
  19. x = (x*m) % n;
  20. }
  21. }
  22. return x;
  23. }

slflpwmd.cpp : last modifiled at 2015/11/27 14:01:42(470 bytes)
created at 2017/10/07 10:26:50
The creation time of this html file is 2017/11/09 14:52:03 (Thu Nov 09 14:52:03 2017).